package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.FoodsInfo;
import com.itheima.pojo.SportsInfo;
import com.itheima.service.PhoneKnowledgeService;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/phoneknowledge")
public class PhoneKnowledgeController {

    @Reference
    private PhoneKnowledgeService phoneKnowledgeService;

    @RequestMapping("/findSportById")
    public Result findSportById(Integer id){
        try{
            List<SportsInfo> sportsInfo = phoneKnowledgeService.findSportById(id);
            return new Result(true, MessageConstant.QUERY_KNOWLEDGE_SUCCESS,sportsInfo);
        }catch (Exception e){
            e.printStackTrace();
            //服务调用失败
            return new Result(false, MessageConstant.QUERY_KNOWLEDGE_FAIL);
        }
    }
}
